#ifndef STX_ALGORITHM_TRANSFORM_HPP
#define STX_ALGORITHM_TRANSFORM_HPP

#include <stx/algorithm/common.hpp>

namespace stx {

template <class InputIterator, class OutputIterator, class UnaryOperation>
inline OutputIterator
transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op)
{
    for (; first != last; ++first, ++result) {
        *result = op(*first);
    }
    return result;
}

template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
inline OutputIterator
transform(
    InputIterator1 first1,
    InputIterator1 last1,
    InputIterator2 first2,
    OutputIterator result,
    BinaryOperation binary_op)
{
    for (; first1 != last1; ++first1, ++first2, ++result) {
        *result = binary_op(*first1, *first2);
    }
    return result;
}

} // namespace stx

#endif // STX_ALGORITHM_TRANSFORM_HPP
